package com.ruoyi.system.api;

import java.util.List;

import feign.RequestLine;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.domain.SysConfig;
import com.ruoyi.system.api.factory.RemoteSysConfigFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;


/**
 * 参数配置微服务接口
 * 
 * @author ruoyi
 * @date 2023-04-26
 */
@FeignClient(contextId = "remoteSysConfigService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteSysConfigFallbackFactory.class)
public interface RemoteSysConfigService
{
    /**
     * 查询参数配置
     * 
     * @param configId 参数配置主键
     * @return 参数配置
     */
    @GetMapping("/inner/config/{configId}")
    public R<SysConfig> selectSysConfigByConfigId(@PathVariable("configId") Long configId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询参数配置列表
     * 
     * @param sysConfig 参数配置
     * @return 参数配置集合
     */
    // @GetMapping(value = "/inner/config/list", consumes = MediaType.APPLICATION_JSON_VALUE)
    // @RequestLine("GET /inner/config/list")
    @PostMapping("/inner/config/list")
    public R<List<SysConfig>> selectSysConfigList(SysConfig sysConfig, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 新增参数配置
     * 
     * @param sysConfig 参数配置
     * @return 结果
     */
    @PostMapping("/inner/config")
    public R<Integer> insertSysConfig(@RequestBody SysConfig sysConfig, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 修改参数配置
     * 
     * @param sysConfig 参数配置
     * @return 结果
     */
    @PutMapping("/inner/config")
    public R<Integer> updateSysConfig(@RequestBody SysConfig sysConfig, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 批量删除参数配置
     * 
     * @param configIds 需要删除的参数配置主键集合
     * @return 结果
     */
    @DeleteMapping("/{configIds}")
    public R<Integer> deleteSysConfigByConfigIds(@PathVariable("configIds") Integer[] configIds, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 修改参数配置
     *
     * @return 结果
     */
    @PutMapping("/inner/config")
    public R<Integer> resetConfigCache(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping("/inner/config/value")
    R<String> selectConfigByKey(String configKey, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
